//
//  CGNewFeatureCell.m
//  SchoolClient
//
//  Created by mac on 15/11/17.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "CGNewFeatureCell.h"
//#import "CGTabBarController.h"
#import "AppDelegate.h"

@interface CGNewFeatureCell ()
@property(nonatomic,strong)UIImageView *imageView;
@property(nonatomic,strong)UIButton *clickMeButton;
@property(nonatomic,assign)CGFloat orightH;
@end

@implementation CGNewFeatureCell

-(UIButton *)clickMeButton{
    
    if (!_clickMeButton) {
        
        self.orightH = SCREEN_HEIGHT - 85;
        if (IS_IPHONE5) {
            self.orightH = SCREEN_HEIGHT - 95;
        }else if (IS_IPHONE6){
            self.orightH = SCREEN_HEIGHT - 110;
        }else if (IS_IPHONE6PLUS){
           self.orightH = SCREEN_HEIGHT - 120;
        }
        
        _clickMeButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2, self.orightH, 160, 40)];
        [_clickMeButton setBackgroundColor:[UIColor clearColor]];
        [_clickMeButton addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside];
      
        [self addSubview:_clickMeButton];
    }

    return _clickMeButton;
}

-(UIImageView *)imageView{
    if (!_imageView) {
        _imageView = [[UIImageView alloc]initWithFrame:self.bounds];
        [self.contentView addSubview:_imageView];
    }

    return _imageView;
}

-(void)setImage:(UIImage *)image{
    _image = image;
    self.imageView.image = image;
}

// 判断当前cell是否是最后一页
-(void)setIndexPath:(NSIndexPath *)indexPath count:(int)count{

    if (indexPath.row == count - 1) {
        self.clickMeButton.hidden = NO;
        
    }else{
        self.clickMeButton.hidden = YES;
    }
}

//点击进入主页面
-(void)start{
    
    // 进入tabBarVc
    AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
    [app.tabBarController setSelectedIndex:0];
    keyWindow.rootViewController = app.tabBarController;
}


@end
